return s->gate;
}
+void pit_time_fired(struct vcpu *v, void *priv)
+{
+ PITChannelState *s = priv;
+ s->count_load_time = hvm_get_clock(v);
+}
+
static inline void pit_load_count(PITChannelState *s, int val)
{
u32 period;
switch (s->mode) {
case 2:
/* create periodic time */
- s->pt = create_periodic_time (s->vcpu, period, 0, 0);
+ s->pt = create_periodic_time (s, period, 0, 0);
break;
case 1:
/* create one shot time */
- s->pt = create_periodic_time (s->vcpu, period, 0, 1);
+ s->pt = create_periodic_time (s, period, 0, 1);
#ifdef DEBUG_PIT
printk("HVM_PIT: create one shot time.\n");
#endif
* period: fire frequency in ns.
*/
struct periodic_time * create_periodic_time(
- struct vcpu *v,
+ PITChannelState *s,
u32 period,
char irq,
char one_shot)
{
+ struct vcpu *v = s->vcpu;
struct periodic_time *pt = &(v->domain->arch.hvm_domain.pl_time.periodic_tm);
if ( pt->enabled ) {
if ( v->vcpu_id != 0 ) {
pt->scheduled = NOW() + period;
set_timer (&pt->timer,pt->scheduled);
pt->enabled = 1;
+ pt->priv = s;
return pt;
}
pt->pending_intr_nr--;
pt->last_plt_gtime += pt->period_cycles;
set_guest_time(v, pt->last_plt_gtime);
+ pit_time_fired(v, pt->priv);
}
}
s_time_t scheduled; /* scheduled timer interrupt */
u64 last_plt_gtime; /* platform time when last IRQ is injected */
struct timer timer; /* ac_timer */
+ void *priv; /* ponit back to platform time source */
};
typedef struct PITState {
extern void hvm_hooks_assist(struct vcpu *v);
extern void pickup_deactive_ticks(struct periodic_time *vpit);
extern u64 hvm_get_guest_time(struct vcpu *v);
-extern struct periodic_time *create_periodic_time(struct vcpu *v, u32 period, char irq, char one_shot);
+extern struct periodic_time *create_periodic_time(PITChannelState *v, u32 period, char irq, char one_shot);
extern void destroy_periodic_time(struct periodic_time *pt);
void pit_init(struct vcpu *v, unsigned long cpu_khz);
void pt_timer_fn(void *data);
+void pit_time_fired(struct vcpu *v, void *priv);
#endif /* __ASM_X86_HVM_VPIT_H__ */